home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
news
/
inn-1.4-l
/
inn-1
/
inn-1.4-linux-0.1
/
bash-patches
/
bash-1.12-fd3.diff
next >
Wrap
Text File
|
1993-08-22
|
2KB
|
60 lines
I found it (we had fixed this a few months back, which is why it's not
reproducible in current development versions). Your gdb guy was close,
but was looking at the wrong thing. He is correct in that gdb manages
something differently from dbx, but that thing is file descriptors, not
memory.)
Bash uses file descriptor 3 for reading the script, because that's the
file descriptor returned by open. When the Configure script uses the
`exec 3>&1' construct, the bash code doesn't know how to handle it,
because stdio doesn't allow swapping file descriptors associated with
FILEs. Bash does ahead and does the dup2, duplicating fd 1 onto fd 3.
The stdio FILE still has file descriptor 3 associated with it,
and tries to read from it, which results in the script attempting to
read from stdout when it goes back for more of the script.
I have appended a patch with code from the current development version
of 1.13 that fixes this.
sh and ksh have always done something like this with the script fd,
moving it to a file descriptor out of the user-accessible range (which
has traditionally been 0-9). The bash problem is harder, since
Posix.2 says that all file descriptors are user-accessible (e.g.,
10>/dev/null redirects file descriptor 10, rather than file descriptor
0 as sh and ksh do). There are no descriptors that are `off-limits'
to the user, so this patch adds a dup2 to getdtablesize() - 1 and hopes
for the best.
The original 1.12 code worked in gdb because gdb uses fd 3 for its own
purposes, so it is open when bash is run, and therefore not used when
bash opens the script file. (The file descriptor returned by the open
is 5, in my case.) This leaves file descriptor 3 free for use by the
`exec'.
*** shell.c.orig Tue Jan 21 00:52:37 1992
--- shell.c Thu Feb 25 07:39:09 1993
***************
*** 706,709 ****
--- 706,720 ----
}
+ {
+ int script_fd;
+
+ script_fd = dup2 (fd, getdtablesize () - 1);
+ if (script_fd)
+ {
+ close (fd);
+ fd = script_fd;
+ }
+ }
+
default_input = fdopen (fd, "r");
--
``The use of history as therapy means the corruption of history as history.''
-- Arthur Schlesinger
Chet Ramey, Case Western Reserve University Internet: chet@po.CWRU.Edu